var fs = require('fs');
function readJson(filePath,callback){
    fs.readFile(filePath,'utf-8',(err,data)=>{
        var dataString = '';
        if(data){
            dataString = '['+data.substring(0,data.length-1)+']';
        }else{
            dataString = '[{"nicheng":"无名","con":"深刻感悟和把握马克思主义真理力量","time":"2018-04-24 20:30:40"}]';
            fs.writeFile(filePath,JSON.stringify(JSON.parse(dataString)[0])+',');
        }
        // res.render('index', { list : dataString ? JSON.parse(dataString).reverse() : [] });
        callback(dataString);
    });
}

module.exports = readJson;
